<template>
  <ant-modal modalWidth="1300" modalHeight="600" :visible="open" :modal-title="formTitle" :adjust-size="true"
    @cancel="cancel">
    <a-form-model ref="form" :model="form"  slot="content" layout="vertical">
      <a-spin :spinning="loading">
      <a-row>

        <a-col :span="24">
          
    <a-card :bordered="false" style="margin-bottom: 10px">
      <!-- 条件搜索 -->
      <div class="table-page-search-wrapper">
        <a-form :labelCol="labelCol" :wrapperCol="wrapperCol" ref="queryForm">
          <a-row :gutter="32">
            <a-col :span="8">
              <a-form-item label="对账状态">
                <a-select placeholder="请选择状态" v-model="form.accountStatus" style="width: 100%" allow-clear>
                  <a-select-option v-for="(d, index) in statementOptions" :key="index" :value="d.dictValue">{{
                    d.dictLabel
                  }}</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="单据阶段">
                <a-select placeholder="请选择单据阶段" v-model="statusArr" style="width: 100%" allow-clear mode="multiple">
                  <a-select-option v-for="(d, index) in statusOptions" :key="index" :value="d.dictValue">{{
                    d.dictLabel
                  }}</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="查询条件">
                <a-input v-model="form.orderParams" placeholder="请输入查询条件"/>
              </a-form-item>
            </a-col>
            
            <a-col :span="8">
              <a-form-item label="日期">
                <a-range-picker format="YYYY-MM-DD" v-model="orderDate"  :show-today="true"/>
              </a-form-item>
            </a-col>
            <a-col :span="8"></a-col>
            <a-col :span="8">
              <span class="table-page-search-submitButtons" style="float: right">
                <a-button type="primary" @click="getDetailList"><a-icon type="search" />查询</a-button>
                <a-button style="margin-left: 8px" @click="resetQuery"><a-icon type="redo" />重置</a-button>
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
    </a-card>
          <a-card :bordered="false" class="table-card">
            <advance-table size="middle" :columns="columns" :data-source="form.list"
            :components="drag(columns,'receivableDetail')" 
            :columnsTitle="'receivableDetail'" @change="handleTableChange"
            :preserveSelectedRowKeys="true"
            :pagination="{
                current: queryParam.pageNum,
                pageSize: queryParam.pageSize,
                pageSizeOptions:queryParam.pageSizeOptions,
                total: total,
                showSizeChanger: true,
                showLessItems: true,
                showQuickJumper: true,
                showTotal: (total, range) => `第 ${range[0]}-${range[1]} 条，总计 ${total} 条`,
                onChange: changeSize,
                onShowSizeChange: onShowSizeChange
            }"
              :bordered="true" rowKey="id" :row-selection="{ selectedRowKeys: selectedRowKeys,getCheckboxProps:getCheckboxProps,onSelect:onSelect, onChange: onSelectChange }">
              <div slot="button" class="table-operations">
                <a-switch style="float:left" checked-children="多选" un-checked-children="单选" v-model="linked" />
                <a-button type="primary"  @click="print" >打印</a-button>
                <a-button type="primary"  @click='exportExcel'>
                  <a-icon />导出
                </a-button>
              </div>
              <span slot="accountStatus" slot-scope="{record}" v-if="record.id">
                <a-tag style="margin-right:0" color="green" v-if="record.accountCode">
                  已生成
                </a-tag>
                <a-tag style="margin-right:0" color="#ccc" v-else>未生成</a-tag>
              </span>
              <span slot="orderStatus" slot-scope="{record}">
                {{ statusFormat(record) }}
              </span>
              
            </advance-table>
              
          </a-card>
        </a-col>
      </a-row>
    </a-spin>
    
    <ant-modal
      :visible="openPrint"
      modal-title="打印应收账款明细"
      :adjust-size="true"
      @cancel="openPrint = false"
      modalHeight="550"
      modalWidth="1000">
      <a-row slot="content">
        <iframe height='425' width='985' style='border:none;min-height: 100vh;width: 100%;' :src='setUrl' ></iframe>
      </a-row>
      <div slot="footer">
        <a-button @click="openPrint = false">关闭</a-button>
      </div>
    </ant-modal>
    </a-form-model>
    <template slot="footer">
      <a-button :disabled="disabled" @click="cancel">
        取消
      </a-button>
      <a-button v-if="select" type="primary" :disabled="disabled" @click="submitSelect(true)">
        确定
      </a-button>
      <a-button v-else type="primary" :disabled="disabled" @click="submitForm(true)">
        对账
      </a-button>
    </template>
  </ant-modal>
</template>
<script>
import BizPayableDetailForm from './BizPayableDetailForm'
export default {
  ...BizPayableDetailForm
}
</script>
<style lang="less" scoped>
.table-operations,
body tr.ant-table-expanded-row:hover .table-operations {
  padding-bottom: 8px;
  text-align: right;
}

.table-operations {
  margin-bottom: 16px;
}

.table-operations>button,
.table-operations .ant-input-affix-wrapper {
  margin-right: 8px;
}

.table_title {
  float: left;
  padding-left: 8px;
  font-weight: 600;
  color: #222222;
  line-height: 30px;
}
</style>
